import unittest
import os
from common.BeautifulReport import BeautifulReport

DIR = os.path.dirname(os.path.abspath(__file__))
logs_dir = os.path.join(DIR, 'logs')
if not os.path.exists(logs_dir):
    os.makedirs(logs_dir)

ENVIRON = 'Offline'  # online -> 线上环境, Offline -> 测试环境。

if __name__ == '__main__':
    # 通过run_pattern 来控制当前执行用例的测试范围， all 是全部用例执行，smoking 是主流程测试
    run_pattern = 'smoking'  # all 全量测试用例执行 /  smoking 冒烟测试执行  /  指定执行文件
    if run_pattern == 'all':
        pattern = 'test_*.py'
    elif run_pattern == 'smoking':
        pattern = 'test_major*.py'
    else:
        pattern = run_pattern + '.py'
    suite = unittest.TestLoader().discover('./test_case', pattern=pattern)
    result = BeautifulReport(suite)
    result.report(filename="report.html", description='测试报告', report_dir='./')